// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Bare Metal Solution API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_baremetalsolution_v2::client::BareMetalSolution;
/// let client = BareMetalSolution::builder().build().await?;
/// // use `client` to make requests to the Bare Metal Solution API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Performs management operations on Bare Metal Solution servers.
///
/// The `baremetalsolution.googleapis.com` service provides management
/// capabilities for Bare Metal Solution servers. To access the API methods, you
/// must assign Bare Metal Solution IAM roles containing the desired permissions
/// to your staff in your Google Cloud project. You must also enable the Bare
/// Metal Solution API. Once enabled, the methods act
/// upon specific servers in your Bare Metal Solution environment.
///
/// # Configuration
///
/// To configure `BareMetalSolution` use the `with_*` methods in the type returned
/// by [builder()][BareMetalSolution::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://baremetalsolution.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::bare_metal_solution::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::bare_metal_solution::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `BareMetalSolution` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `BareMetalSolution` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct BareMetalSolution {
    inner: std::sync::Arc<dyn super::stub::dynamic::BareMetalSolution>,
}

impl BareMetalSolution {
    /// Returns a builder for [BareMetalSolution].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_baremetalsolution_v2::client::BareMetalSolution;
    /// let client = BareMetalSolution::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::bare_metal_solution::ClientBuilder {
        gax::client_builder::internal::new_builder(
            super::builder::bare_metal_solution::client::Factory,
        )
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::BareMetalSolution + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::BareMetalSolution>>
    {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::BareMetalSolution> {
        super::transport::BareMetalSolution::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::BareMetalSolution> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::BareMetalSolution::new)
    }

    /// List servers in a given project and location.
    pub fn list_instances(&self) -> super::builder::bare_metal_solution::ListInstances {
        super::builder::bare_metal_solution::ListInstances::new(self.inner.clone())
    }

    /// Get details about a single server.
    pub fn get_instance(&self) -> super::builder::bare_metal_solution::GetInstance {
        super::builder::bare_metal_solution::GetInstance::new(self.inner.clone())
    }

    /// Update details of a single server.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_instance(&self) -> super::builder::bare_metal_solution::UpdateInstance {
        super::builder::bare_metal_solution::UpdateInstance::new(self.inner.clone())
    }

    /// RenameInstance sets a new name for an instance.
    /// Use with caution, previous names become immediately invalidated.
    pub fn rename_instance(&self) -> super::builder::bare_metal_solution::RenameInstance {
        super::builder::bare_metal_solution::RenameInstance::new(self.inner.clone())
    }

    /// Perform an ungraceful, hard reset on a server. Equivalent to shutting the
    /// power off and then turning it back on.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn reset_instance(&self) -> super::builder::bare_metal_solution::ResetInstance {
        super::builder::bare_metal_solution::ResetInstance::new(self.inner.clone())
    }

    /// Starts a server that was shutdown.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn start_instance(&self) -> super::builder::bare_metal_solution::StartInstance {
        super::builder::bare_metal_solution::StartInstance::new(self.inner.clone())
    }

    /// Stop a running server.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn stop_instance(&self) -> super::builder::bare_metal_solution::StopInstance {
        super::builder::bare_metal_solution::StopInstance::new(self.inner.clone())
    }

    /// Enable the interactive serial console feature on an instance.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn enable_interactive_serial_console(
        &self,
    ) -> super::builder::bare_metal_solution::EnableInteractiveSerialConsole {
        super::builder::bare_metal_solution::EnableInteractiveSerialConsole::new(self.inner.clone())
    }

    /// Disable the interactive serial console feature on an instance.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn disable_interactive_serial_console(
        &self,
    ) -> super::builder::bare_metal_solution::DisableInteractiveSerialConsole {
        super::builder::bare_metal_solution::DisableInteractiveSerialConsole::new(
            self.inner.clone(),
        )
    }

    /// Detach LUN from Instance.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn detach_lun(&self) -> super::builder::bare_metal_solution::DetachLun {
        super::builder::bare_metal_solution::DetachLun::new(self.inner.clone())
    }

    /// Lists the public SSH keys registered for the specified project.
    /// These SSH keys are used only for the interactive serial console feature.
    pub fn list_ssh_keys(&self) -> super::builder::bare_metal_solution::ListSSHKeys {
        super::builder::bare_metal_solution::ListSSHKeys::new(self.inner.clone())
    }

    /// Register a public SSH key in the specified project for use with the
    /// interactive serial console feature.
    pub fn create_ssh_key(&self) -> super::builder::bare_metal_solution::CreateSSHKey {
        super::builder::bare_metal_solution::CreateSSHKey::new(self.inner.clone())
    }

    /// Deletes a public SSH key registered in the specified project.
    pub fn delete_ssh_key(&self) -> super::builder::bare_metal_solution::DeleteSSHKey {
        super::builder::bare_metal_solution::DeleteSSHKey::new(self.inner.clone())
    }

    /// List storage volumes in a given project and location.
    pub fn list_volumes(&self) -> super::builder::bare_metal_solution::ListVolumes {
        super::builder::bare_metal_solution::ListVolumes::new(self.inner.clone())
    }

    /// Get details of a single storage volume.
    pub fn get_volume(&self) -> super::builder::bare_metal_solution::GetVolume {
        super::builder::bare_metal_solution::GetVolume::new(self.inner.clone())
    }

    /// Update details of a single storage volume.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_volume(&self) -> super::builder::bare_metal_solution::UpdateVolume {
        super::builder::bare_metal_solution::UpdateVolume::new(self.inner.clone())
    }

    /// RenameVolume sets a new name for a volume.
    /// Use with caution, previous names become immediately invalidated.
    pub fn rename_volume(&self) -> super::builder::bare_metal_solution::RenameVolume {
        super::builder::bare_metal_solution::RenameVolume::new(self.inner.clone())
    }

    /// Skips volume's cooloff and deletes it now.
    /// Volume must be in cooloff state.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn evict_volume(&self) -> super::builder::bare_metal_solution::EvictVolume {
        super::builder::bare_metal_solution::EvictVolume::new(self.inner.clone())
    }

    /// Emergency Volume resize.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn resize_volume(&self) -> super::builder::bare_metal_solution::ResizeVolume {
        super::builder::bare_metal_solution::ResizeVolume::new(self.inner.clone())
    }

    /// List network in a given project and location.
    pub fn list_networks(&self) -> super::builder::bare_metal_solution::ListNetworks {
        super::builder::bare_metal_solution::ListNetworks::new(self.inner.clone())
    }

    /// List all Networks (and used IPs for each Network) in the vendor account
    /// associated with the specified project.
    pub fn list_network_usage(&self) -> super::builder::bare_metal_solution::ListNetworkUsage {
        super::builder::bare_metal_solution::ListNetworkUsage::new(self.inner.clone())
    }

    /// Get details of a single network.
    pub fn get_network(&self) -> super::builder::bare_metal_solution::GetNetwork {
        super::builder::bare_metal_solution::GetNetwork::new(self.inner.clone())
    }

    /// Update details of a single network.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_network(&self) -> super::builder::bare_metal_solution::UpdateNetwork {
        super::builder::bare_metal_solution::UpdateNetwork::new(self.inner.clone())
    }

    /// Takes a snapshot of a boot volume.
    /// Returns INVALID_ARGUMENT if called for a non-boot volume.
    pub fn create_volume_snapshot(
        &self,
    ) -> super::builder::bare_metal_solution::CreateVolumeSnapshot {
        super::builder::bare_metal_solution::CreateVolumeSnapshot::new(self.inner.clone())
    }

    /// Uses the specified snapshot to restore its parent volume.
    /// Returns INVALID_ARGUMENT if called for a non-boot volume.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn restore_volume_snapshot(
        &self,
    ) -> super::builder::bare_metal_solution::RestoreVolumeSnapshot {
        super::builder::bare_metal_solution::RestoreVolumeSnapshot::new(self.inner.clone())
    }

    /// Deletes a volume snapshot.
    /// Returns INVALID_ARGUMENT if called for a non-boot volume.
    pub fn delete_volume_snapshot(
        &self,
    ) -> super::builder::bare_metal_solution::DeleteVolumeSnapshot {
        super::builder::bare_metal_solution::DeleteVolumeSnapshot::new(self.inner.clone())
    }

    /// Returns the specified snapshot resource.
    /// Returns INVALID_ARGUMENT if called for a non-boot volume.
    pub fn get_volume_snapshot(&self) -> super::builder::bare_metal_solution::GetVolumeSnapshot {
        super::builder::bare_metal_solution::GetVolumeSnapshot::new(self.inner.clone())
    }

    /// Retrieves the list of snapshots for the specified volume.
    /// Returns a response with an empty list of snapshots if called
    /// for a non-boot volume.
    pub fn list_volume_snapshots(
        &self,
    ) -> super::builder::bare_metal_solution::ListVolumeSnapshots {
        super::builder::bare_metal_solution::ListVolumeSnapshots::new(self.inner.clone())
    }

    /// Get details of a single storage logical unit number(LUN).
    pub fn get_lun(&self) -> super::builder::bare_metal_solution::GetLun {
        super::builder::bare_metal_solution::GetLun::new(self.inner.clone())
    }

    /// List storage volume luns for given storage volume.
    pub fn list_luns(&self) -> super::builder::bare_metal_solution::ListLuns {
        super::builder::bare_metal_solution::ListLuns::new(self.inner.clone())
    }

    /// Skips lun's cooloff and deletes it now.
    /// Lun must be in cooloff state.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn evict_lun(&self) -> super::builder::bare_metal_solution::EvictLun {
        super::builder::bare_metal_solution::EvictLun::new(self.inner.clone())
    }

    /// Get details of a single NFS share.
    pub fn get_nfs_share(&self) -> super::builder::bare_metal_solution::GetNfsShare {
        super::builder::bare_metal_solution::GetNfsShare::new(self.inner.clone())
    }

    /// List NFS shares.
    pub fn list_nfs_shares(&self) -> super::builder::bare_metal_solution::ListNfsShares {
        super::builder::bare_metal_solution::ListNfsShares::new(self.inner.clone())
    }

    /// Update details of a single NFS share.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_nfs_share(&self) -> super::builder::bare_metal_solution::UpdateNfsShare {
        super::builder::bare_metal_solution::UpdateNfsShare::new(self.inner.clone())
    }

    /// Create an NFS share.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_nfs_share(&self) -> super::builder::bare_metal_solution::CreateNfsShare {
        super::builder::bare_metal_solution::CreateNfsShare::new(self.inner.clone())
    }

    /// RenameNfsShare sets a new name for an nfsshare.
    /// Use with caution, previous names become immediately invalidated.
    pub fn rename_nfs_share(&self) -> super::builder::bare_metal_solution::RenameNfsShare {
        super::builder::bare_metal_solution::RenameNfsShare::new(self.inner.clone())
    }

    /// Delete an NFS share. The underlying volume is automatically deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_nfs_share(&self) -> super::builder::bare_metal_solution::DeleteNfsShare {
        super::builder::bare_metal_solution::DeleteNfsShare::new(self.inner.clone())
    }

    /// List the budget details to provision resources on a given project.
    pub fn list_provisioning_quotas(
        &self,
    ) -> super::builder::bare_metal_solution::ListProvisioningQuotas {
        super::builder::bare_metal_solution::ListProvisioningQuotas::new(self.inner.clone())
    }

    /// Submit a provisiong configuration for a given project.
    pub fn submit_provisioning_config(
        &self,
    ) -> super::builder::bare_metal_solution::SubmitProvisioningConfig {
        super::builder::bare_metal_solution::SubmitProvisioningConfig::new(self.inner.clone())
    }

    /// Get ProvisioningConfig by name.
    pub fn get_provisioning_config(
        &self,
    ) -> super::builder::bare_metal_solution::GetProvisioningConfig {
        super::builder::bare_metal_solution::GetProvisioningConfig::new(self.inner.clone())
    }

    /// Create new ProvisioningConfig.
    pub fn create_provisioning_config(
        &self,
    ) -> super::builder::bare_metal_solution::CreateProvisioningConfig {
        super::builder::bare_metal_solution::CreateProvisioningConfig::new(self.inner.clone())
    }

    /// Update existing ProvisioningConfig.
    pub fn update_provisioning_config(
        &self,
    ) -> super::builder::bare_metal_solution::UpdateProvisioningConfig {
        super::builder::bare_metal_solution::UpdateProvisioningConfig::new(self.inner.clone())
    }

    /// RenameNetwork sets a new name for a network.
    /// Use with caution, previous names become immediately invalidated.
    pub fn rename_network(&self) -> super::builder::bare_metal_solution::RenameNetwork {
        super::builder::bare_metal_solution::RenameNetwork::new(self.inner.clone())
    }

    /// Retrieves the list of OS images which are currently approved.
    pub fn list_os_images(&self) -> super::builder::bare_metal_solution::ListOSImages {
        super::builder::bare_metal_solution::ListOSImages::new(self.inner.clone())
    }

    /// Lists information about the supported locations for this service.
    pub fn list_locations(&self) -> super::builder::bare_metal_solution::ListLocations {
        super::builder::bare_metal_solution::ListLocations::new(self.inner.clone())
    }

    /// Gets information about a location.
    pub fn get_location(&self) -> super::builder::bare_metal_solution::GetLocation {
        super::builder::bare_metal_solution::GetLocation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::bare_metal_solution::GetOperation {
        super::builder::bare_metal_solution::GetOperation::new(self.inner.clone())
    }
}
